package com.gadgets.busi.bm01.start;

import com.alibaba.fastjson.JSON;
import com.gadgets.busi.bm01.common.GadgetsBm01Constant;
import com.gadgets.framework.start.AbstractInitLoaderProcess;
import com.gadgets.framework.thread.basic.ThreadPoolConfiguration;
import com.gadgets.framework.thread.pool.GadgetsThreadPool;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * The type Bm 01 thread register.
 *
 * @author UncleXiu
 * @version V1.0.0
 * @data 2021 -07-17
 */
@Component
public class Bm01ThreadRegister extends AbstractInitLoaderProcess {

    /**
     * Instantiates a new Bm 01 thread register.
     */
    public Bm01ThreadRegister() {
        super(Integer.MIN_VALUE+501);
    }

    /**
     * 初始化方法
     *
     * @param context Spring上下文
     */
    @Override
    public void initLoad(ApplicationContext context) {
        logger.info("Bm01模块线程池开始注册");
        ThreadPoolConfiguration configuration = new ThreadPoolConfiguration();
        configuration.setModuelNo(GadgetsBm01Constant.BM01_MODUEL_NO);
        configuration.setMaxThread(5);
        configuration.setMinThread(1);
        configuration.setFlowLimitSize(1000);
        configuration.setLevelDownThreshold(0.3);
        configuration.setLevelUpThreshold(0.5);
        configuration.setCurrentThread(1);
        logger.info("Bm01模块线程池注册信息：{}", JSON.toJSONString(configuration));
        GadgetsThreadPool.registryModuel(configuration);
        logger.info("Bm01模块线程池完成注册");
    }

}
